unit uMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, uGeneric, ExtCtrls, ComCtrls, TabNotBk;

type
  TShowControl = class(TTabbedNotebook)

  end;

  TForm1 = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    cboxFind: TComboBox;
    btnNext: TButton;
    Label5: TLabel;
    Label6: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel4: TPanel;
    Panel5: TPanel;
    Label4: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    ScrollBox1: TScrollBox;
    Label10: TLabel;
    GroupBox1: TGroupBox;
    Label11: TLabel;
    Label14: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure cboxFindKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure btnNextClick(Sender: TObject);
    procedure cboxFindSelect(Sender: TObject);
  private
    { Private declarations }

    procedure WMHotkey(var Msg: TWMHotkey); message WM_HOTKEY;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  oFindLabel, oMarkLabel;

var
  vFindLabel: TFindLabel = nil;
  vNext: Integer = 0;

{$R *.dfm}

procedure TForm1.btnNextClick(Sender: TObject);
begin
  if vFindLabel.Counts > 0 then
  begin
    if vNext = vFindLabel.Counts then
    begin
      vNext := 0;
      vFindLabel.RepaintAll(clYellow);
      Exit;
    end;
    if (TLabel(vFindLabel.FindLabel[vNext]).Parent is TTabPage) then
      TShowControl(TLabel(vFindLabel.FindLabel[vNext]).Parent).ShowControl(TControl(vFindLabel.FindLabel[vNext]));
    if (TLabel(vFindLabel.FindLabel[vNext]).Parent is TScrollBox) then
     TScrollBox(TLabel(vFindLabel.FindLabel[vNext]).Parent).HorzScrollBar.Position := TLabel(vFindLabel.FindLabel[vNext]).Top;
    if vNext > 0 then
      vFindLabel.FindLabel[vNext-1].Repaint(clYellow);
    vFindLabel.FindLabel[vNext].Repaint(clTeal);
    Inc(vNext);
  end;
end;

procedure TForm1.cboxFindKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  vNext := 0;
  vFindLabel.Mark := cboxFind.Text;
  vFindLabel.Sensitive := False;
  vFindLabel.MarkLabel;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  CarregaComboBox(@Form1, @cboxFind);
  cboxFind.AutoComplete := False;
  vFindLabel := TFindLabel.Create;
  vFindLabel.Form := Form1;
  vFindLabel.RepaintOnMove := True;
  vFindLabel.RepaintColor := clYellow;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FreeAndNil(vFindLabel);
end;

procedure TForm1.WMHotkey(var Msg: TWMHotkey);
begin
  if Msg.HotKey = 1 then
    ;
end;

procedure TForm1.cboxFindSelect(Sender: TObject);
begin
  vNext := 0;
  vFindLabel.Mark := cboxFind.Text;
  vFindLabel.Sensitive := True;
  vFindLabel.MarkLabel;
end;

end.
